Body Event
Description:
This is just a demonstration record showing some signal slot events that are used when the receivingContact property of a Body is set to true. And they are meant to be used for collision detection between Body objects.
Usage:
-- you can register for these events using codes
body.receivingContact = true
body:slot("ContactStart", function(other: Body, point: Vec2, normal: Vec2, enabled: boolean)
print("A body has contacted", other, point, normal, enabled)
end)
BodyEnter
Type: Node Event.
Description:
Triggers when a Body object collides with a sensor object. This event triggers only when the Body attached with any fixture as sensor.
Signature:
["BodyEnter"]: function(other: Body, sensorTag: integer)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is colliding with. |
sensorTag | integer | The tag of the sensor that triggered this collision. |
BodyLeave
Type: Node Event.
Description:
Triggers when a Body
object is no longer colliding with a sensor object. This event triggers only when the Body attached with any fixture as sensor.
Signature:
["BodyLeave"]: function(other: Body, sensorTag: integer)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is no longer colliding with. |
sensorTag | integer | The tag of the sensor that triggered this collision. |
ContactStart
Type: Node Event.
Description:
Triggers when a Body
object starts to collide with another object. This event triggers only when the receivingContact
property of the Body
is set to true.
Signature:
["ContactStart"]: function(other: Body, point: Vec2, normal: Vec2, enabled: boolean)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is colliding with. |
point | Vec2 | The point of collision in world coordinates. |
normal | Vec2 | The normal vector of the contact surface in world coordinates. |
enabled | boolean | Whether the contact is enabled or not. Collisions that are filtered out will still trigger this event, but the enabled state will be false. |
ContactEnd
Type: Node Event.
Description:
Triggers when a Body
object stops colliding with another object. This event triggers only when the receivingContact
property of the Body
is set to true.
Signature:
["ContactEnd"]: function(other: Body, point: Vec2, normal: Vec2)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is no longer colliding with. |
point | Vec2 | The point of collision in world coordinates. |
normal | Vec2 | The normal vector of the contact surface in world coordinates. |